﻿/*
 * 由SharpDevelop创建。
 * 用户： 汪伟威
 * 日期: 2015/4/27
 * 时间: 17:36
 * 
 */
using System;
using OpenNETCF.ORM;
using System.Linq;
using System.Collections.Generic;

namespace OpenNETCFSQLiteDemo
{
	/// <summary>
	/// Description of UserDal.
	/// </summary>
	public class UserDal
	{
		SQLiteDataStore store;
		public UserDal(SQLiteDataStore store)
		{
			this.store = store;
		}
		
		public IList<UserInfo> GetAll()
		{
			return store.Select<UserInfo>().ToList();
		}
		
		public UserInfo GetById(int id)
		{
			return store.Select<UserInfo>(x => x.ID == id).FirstOrDefault();
		}
		
		public void Insert(UserInfo entity)
		{
			store.Insert(entity);
		}
		
		public void UpdatePassword(UserInfo entity)
		{
			store.Update(entity, "Password");
		}
		
		public void Update(UserInfo entity)
		{
			store.Update(entity);
		}
		
		public void Delete(UserInfo entity)
		{
			this.Delete(entity);
		}
		
		public void Delete(int id)
		{
			store.Delete<UserInfo>(id);
		}
	}
}
